﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ModBot.ConfigBuilder.Providers
{
    public class ModBotSettingsProvider
    {
        #region Public properties
        /// <summary>
        /// Gets or sets control over melee actions.
        /// </summary>
        public Boolean DoMelee{ get; set; }

        /// <summary>
        /// Gets or sets control over heal actions.
        /// </summary>
        public Boolean DoHeals { get; set; }

        /// <summary>
        /// Gets or sets control over buff actions.
        /// </summary>
        public Boolean DoBuffs { get; set; }

        /// <summary>
        /// Gets or sets control over debuff actions.
        /// </summary>
        public Boolean DoDebuffs { get; set; }

        /// <summary>
        /// Gets or sets control over event actions.
        /// </summary>
        public Boolean DoEvents { get; set; }

        /// <summary>
        /// Gets or sets control over cure actions.
        /// </summary>
        public Boolean DoCures { get; set; }

        /// <summary>
        /// Gets or sets control over melee actions.
        /// </summary>
        public Boolean DoPull { get; set; }

        /// <summary>
        /// Gets or sets control over pet actions.
        /// </summary>
        public Boolean DoPet { get; set; }

        /// <summary>
        /// Gets or sets control over sit actions.
        /// </summary>
        public Boolean DoSit { get; set; }

        /// <summary>
        /// Gets or sets control over loot actions.
        /// </summary>
        public Boolean DoLoot { get; set; }

        /// <summary>
        /// Gets or sets control over food and drink actions.
        /// </summary>
        public Boolean DoFW { get; set; }

        /// <summary>
        /// Gets or sets control over forage actions.
        /// </summary>
        public Boolean DoForage { get; set; }

        /// <summary>
        /// Gets or sets forage ini file name.
        /// </summary>
        public string ForageIni { get; set; }

        /// <summary>
        /// Gets or sets control over afk actions.
        /// </summary>
        public Boolean DoAfk { get; set; }

        /// <summary>
        /// Gets or sets control over mount actions.
        /// </summary>
        public Boolean DoMount { get; set; }

        /// <summary>
        /// Gets or sets the mount to cast
        /// [Spell,Item,AA name|gem#,item,alt]
        /// example: Collapsable Roboboar|item (MQ2Cast syntax without quotes)
        /// </summary>
        public string MountCast{get;set;}

        /// <summary>
        /// Gets or sets the list of masters the bot responds to.
        /// Comma delimited list of names. Can also use ${NetBots.Client} to designate that any chars using NetBots can act as master.
        /// ex. example: [Bob,John,Billy]
        /// </summary>
        public string MasterList {get;set;}

        /// <summary>
        /// Gets or sets the list main assists.
        /// Comma delimited list of names. This variable will also be set when you designate a 
        /// character using  either the Main Tank or Main Assist group roles. 
        /// Can also use ${Group.MainTank.Name} to auto set this to whomever is set in the group main tank role.
        /// ex. [Meat,Brutis]
        /// </summary>
        public string TankName {get;set;}

        /// <summary>
        /// Gets or sets the radius to monitor for NPCs
        /// ex. example: [100]
        /// </summary>
        public int Radius{get;set;}

        /// <summary>
        /// Gets or sets the list of targets to exclude.
        /// Pipe delimited names to exclude, don't forget Pipe at the end.
        /// ex. [a hollow tree|a broken barrel|] 
        /// </summary>
        public Boolean ExcludeList {get;set;}
        
        /// <summary>
        /// Gets or sets the radius to check for safe sitting.
        /// ex. example: [75]
        /// </summary>
        public int SitAggroRadiusCheck { get; set; }

        /// <summary>
        /// Gets or sets a custom for use when AFK.
        /// ex. example: [Not now, thanks]
        /// </summary>
        public string AfkMessage { get; set; }

        /// <summary>
        /// Gets or sets a value which determines whether to camp to 
        /// desktop to save res timer. This way the macro will know if 
        /// you died and had to camp out.
        /// </summary>
        public Boolean DeathSlot { get; set; }


        /// <summary>
        /// Gets or sets the path and filename of the network ini file. Option for a network 
        /// based INI file for scripts and path playback (mbwayplay and mbwaypnt.ini) file.
        /// File must be prefixed by "Network-" or "Net-".
        /// ex. example: NetworkINI=X:\shared\modbot\mb_network.ini 
        /// </summary>
        public string NetworkIni { get; set; }

        /// <summary>
        /// Gets or sets the name of the trader to login when using the campout command
        /// /bc campout trader will log in whatever toon you have set in the TraderName variable.
        /// Second argument (|bazaar trader) will log in the toon and run the bazaar macro with 
        /// the trader option (or any other mac+options you want there.) 
        /// ex. example: [toon name|bazaar trader]
        /// </summary>
        public string TraderName { get; set; }

        /// <summary>
        /// Gets or sets the distance the follower should stay from the followee
        /// ex. example: [20]        
        /// </summary>
        public int FollowDistance { get; set; }

        /// <summary>
        /// Gets or sets the spell to cast for creating or recalling a pet.
        /// PLEASE NOTE: As of 3.499 beta, PetCast is no longer needed. 
        /// You can now add pet to "AB" section by setting ABTarTypeX=petspell (or petcast). 
        /// Pets won't be cast unless DoBuffs and DoPet are true. Also shouldn't cast if in combat 
        /// unless "cbt" is included in ABTarType. When used with modbuff, Persistent Minion is also 
        /// used automatically if you have it, and no extra entry needed. 
        /// * Can also use for charming:
        /// * [charm AdvDebuff Spell Number NPC type 0=any 1=undead,vampyre 2=animal 3=summoned 4=(specify name type) list of names]
        /// * Example: PetCast=charm 4 4 "lowland basilisk,a emerald drake" 
        /// * For Cleric Hammer type pets that you only want to cast / have while in combat, you MUST have DoPet set to False AND have PetCast=pet spell name|gem#,item,alt) 
        /// </summary>
        /// ex. Example: PetCast=Animate Dead|gem8|smii
       
        public string PetCast { get; set; }

        /// <summary>
        /// Gets or sets a value representing whether or not pet taunt is used.
        /// </summary>
        public Boolean PetAggro { get; set; }

        /// <summary>
        /// Gets or sets a value representing whether your pet should attack on assist.
        /// </summary>
        public Boolean PetAssist { get; set; }

        /// <summary>
        /// Gets or sets the swappable foci to be used when summoning your pet.
        /// Any spell foci you want to swap in for this spell using MQ2Cast syntax, 
        /// you must have previously created the set via the MQ2Bandolier 
        /// plugin /createset command. 
        /// [-bandolier|petfoci]        
        /// </summary>
        public string PetFoci { get; set; }

        /// <summary>
        /// Gets or sets the name of the spell to be used for shrinking pets.
        /// [pet shrink spell name|gem#]
        /// * Leave blank if you don't want your pet shrunk.
        /// * Otherwise, format it for standard /casting lines
        /// ex. example: PetShrinkSpell=Tiny Companion|gem9
        /// </summary>
        public string PetShrinkSpell { get; set; }
        
        /// <summary>
        /// Gets or sets the spell to cast for summoning food.
        /// These entries appear when DoFW is set to TRUE. Use MQ2Cast syntax for spell entry.
        /// [spell name,item name,alt name|gem#,item,alt]
        /// </summary>
        public string SummonFood { get; set; }

        /// <summary>
        /// Gets or sets the spell to cast for summoning drink.
        /// These entries appear when DoFW is set to TRUE. Use MQ2Cast syntax for spell entry.
        /// [spell name,item name,alt name|gem#,item,alt]
        /// </summary>        
        public string SummonDrink { get; set; }

        /// <summary>
        /// Gets or sets the follow stick command.
        /// </summary>
        public string FollowStick { get; set; }

        /// <summary>
        /// Gets or sets the pet shrink toggle.
        /// </summary>
        public Boolean PetShrink { get; set; }
        #endregion

        #region Child Providers
        public MeleeSettingsProvider MeleeSettingsProvider { get; set; }
        public HealSettingsProvider HealSettingsProvider { get; set; }
        public BuffSettingsProvider BuffSettingsProvider { get; set; }
        public DebuffSettingsProvider DebuffSettingsProvider { get; set; }
        public EventSettingsProvider EventSettingsProvider { get; set; }
        public PullSettingsProvider PullSettingsProvider { get; set; }
        #endregion

        public ModBotSettingsProvider() 
        {
            this.DoMelee = Defaults.Default_Settings_DoMelee;
            this.DoHeals = Defaults.Default_Settings_DoHeals;
            this.DoBuffs = Defaults.Default_Settings_DoBuffs;
            this.DoDebuffs = Defaults.Default_Settings_DoDebuffs;
            this.DoEvents = Defaults.Default_Settings_DoEvents;
            this.DoCures = Defaults.Default_Settings_DoCures;
            this.DoPull = Defaults.Default_Settings_DoPull;
            this.DoPet = Defaults.Default_Settings_DoPet;
            this.DoSit = Defaults.Default_Settings_DoSit;
            this.DoLoot = Defaults.Default_Settings_DoLoot;
            this.DoFW = Defaults.Default_Settings_DoFW;
            this.DoForage = Defaults.Default_Settings_DoForage;
            this.ForageIni = Defaults.Default_Settings_ForageIni;
            this.DoAfk = Defaults.Default_Settings_DoAfk;
            this.DoMount = Defaults.Default_Settings_DoMount;
            this.MountCast = Defaults.Default_Settings_MountCast;
            this.MasterList = Defaults.Default_Settings_MasterList;
            this.TankName = Defaults.Default_Settings_TankName;
            this.Radius = Defaults.Default_Settings_Radius;
            this.SitAggroRadiusCheck = Defaults.Default_Settings_SitAggroRadiusCheck;
            this.AfkMessage = Defaults.Default_Settings_AfkMessage;
            this.DeathSlot = Defaults.Default_Settings_DeathSlot;
            this.NetworkIni = Defaults.Default_Settings_NetworkIni;
            this.TraderName = Defaults.Default_Settings_TraderName;
            this.FollowDistance = Defaults.Default_Settings_FollowDistance;
            this.FollowStick = Defaults.Default_Settings_FollowStick;
            this.PetCast = Defaults.Default_Settings_PetCast;
            this.PetAggro = Defaults.Default_Settings_PetAggro;
            this.PetFoci = Defaults.Default_Settings_PetFoci;
            this.PetShrinkSpell = Defaults.Default_Settings_PetShrinkSpell;
            this.PetShrink = Defaults.Default_Settings_PetShrink;
            this.PetAssist = Defaults.Default_Settings_PetAssist;

            MeleeSettingsProvider = new MeleeSettingsProvider(this);
            HealSettingsProvider = new HealSettingsProvider(this);
            BuffSettingsProvider = new BuffSettingsProvider(this);
            DebuffSettingsProvider = new DebuffSettingsProvider(this);
            EventSettingsProvider = new EventSettingsProvider(this);
            PullSettingsProvider = new PullSettingsProvider(this);
        }

        public override string ToString()
        {
            string title = " Generated by ModBot Configuration Builder v" + SharedLib.AssemblyVersion;
            
            #region Format String
            string formatString =
                SharedLib.CreateCommentBlock(title, SharedLib.NewLine) +
                "[Settings]\r\n" +
                "DoMelee={0}\r\n" +
                "DoHeals={1}\r\n" +
                "DoBuffs={2}\r\n" +
                "DoDebuffs={3}\r\n" +
                "DoEvents={4}\r\n" +
                "DoCures={5}\r\n" +
                "DoPull={6}\r\n" +
                "DoPet={7}\r\n" +
                "DoSit={8}\r\n" +
                "DoLoot={9}\r\n" +
                "DoFW={10}\r\n" +
                "DoForage={11}\r\n" +
                "ForageIni={12}\r\n" +
                "DoAfk={13}\r\n" +
                "DoMount={14}\r\n" +
                "MountCast={15}\r\n" +
                "MasterList={16}\r\n" +
                "TankName={17}\r\n" +
                "Radius={18}\r\n" +
                "SitAggroRadiusCheck={19}\r\n" +
                "AfkMessage={20}\r\n" +
                "DeathSlot={21}\r\n" +
                "NetworkIni={22}\r\n" +
                "TraderName={23}\r\n" +
                "FollowDistance={24}\r\n" +
                "FollowStick={25}\r\n" +
                "PetCast={26}\r\n" +
                "PetAggro={27}\r\n" +
                "PetAssist={28}\r\n" +
                "PetFoci={29}\r\n" +
                "PetShrinkSpell={30}\r\n" +
                "PetShrink={31}\r\n" +
                "PetAssist={32}\r\n\r\n" +
                SharedLib.CreateCommentBlock("Melee Configuration".PadLeft(76, ' '), SharedLib.NewLine, true) +
                "{33}\r\n" +
                SharedLib.CreateCommentBlock("Heal Configuration".PadLeft(76, ' '), SharedLib.NewLine, true) +
                "{34}\r\n" +
                SharedLib.CreateCommentBlock("Buff Configuration".PadLeft(76, ' '), SharedLib.NewLine, true) +
                "{35}\r\n" +
                SharedLib.CreateCommentBlock("Debuff Configuration".PadLeft(76, ' '), SharedLib.NewLine, true) +
                "{36}\r\n" +
                SharedLib.CreateCommentBlock("Event Configuration".PadLeft(76, ' '), SharedLib.NewLine, true) +
                "{37}\r\n" +
                SharedLib.CreateCommentBlock("Pull Configuration".PadLeft(76, ' '), SharedLib.NewLine, true) +
                "{38}\r\n";
           
            
            #endregion

            return string.Format(formatString,
                DoMelee,
                DoHeals,
                DoBuffs,
                DoDebuffs,
                DoEvents,
                DoCures,
                DoPull,
                DoPet,
                DoSit,
                DoLoot,
                DoFW,
                DoForage,
                ForageIni,
                DoAfk,
                DoMount,
                MountCast,
                MasterList,
                TankName,
                Radius,
                SitAggroRadiusCheck,
                AfkMessage,
                DeathSlot,
                NetworkIni,
                TraderName,
                FollowDistance,
                FollowStick,
                PetCast,
                PetAggro,
                PetAssist,
                PetFoci,
                PetShrinkSpell,
                PetShrink,
                PetAssist,
                MeleeSettingsProvider.ToString(),
                HealSettingsProvider.ToString(),
                BuffSettingsProvider.ToString(),
                DebuffSettingsProvider.ToString(),
                EventSettingsProvider.ToString(),
                PullSettingsProvider.ToString());

        }

        public static ModBotSettingsProvider LoadFromINI(string filepath)
        {
            ModBotSettingsProvider provider = new ModBotSettingsProvider();
            try
            {
                provider.DoMelee = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoMelee), Defaults.Default_Settings_DoMelee);
                provider.DoHeals = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoHeals), Defaults.Default_Settings_DoHeals);
                provider.DoBuffs = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoBuffs), Defaults.Default_Settings_DoBuffs);
                provider.DoDebuffs = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoDebuffs), Defaults.Default_Settings_DoDebuffs);
                provider.DoEvents = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoEvents), Defaults.Default_Settings_DoEvents);
                provider.DoCures = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoCures), Defaults.Default_Settings_DoCures);
                provider.DoPull = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoPull), Defaults.Default_Settings_DoPull);
                provider.DoPet = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoPet), Defaults.Default_Settings_DoPet);
                provider.DoSit = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoSit), Defaults.Default_Settings_DoSit);
                provider.DoLoot = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoLoot), Defaults.Default_Settings_DoLoot);
                provider.DoFW = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoFW), Defaults.Default_Settings_DoFW);
                provider.DoForage = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoForage), Defaults.Default_Settings_DoForage);
                provider.ForageIni = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_ForageIni);
                provider.DoAfk = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoAfk), Defaults.Default_Settings_DoAfk);
                provider.DoMount = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoMount), Defaults.Default_Settings_DoMount);
                provider.MountCast = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_MountCast);
                provider.MasterList = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_MasterList);
                provider.TankName = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_TankName);
                provider.Radius = SharedLib.ConvertToInt32(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_Radius), Defaults.Default_Settings_Radius);
                provider.SitAggroRadiusCheck = SharedLib.ConvertToInt32(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_SitAggroRadiusCheck), Defaults.Default_Settings_SitAggroRadiusCheck);
                provider.AfkMessage = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_AfkMessage);
                provider.DeathSlot = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DeathSlot), Defaults.Default_Settings_DoMelee);
                provider.NetworkIni = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_NetworkIni);
                provider.TraderName = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_TraderName);
                provider.FollowDistance = SharedLib.ConvertToInt32(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_FollowDistance), Defaults.Default_Settings_FollowDistance);
                provider.FollowStick = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_FollowStick);
                provider.PetCast = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetCast);
                provider.PetAggro = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetAggro), Defaults.Default_Settings_DoMelee);
                provider.PetFoci = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetFoci);
                provider.PetShrinkSpell = IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetShrinkSpell);
                provider.PetShrink = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetShrink), Defaults.Default_Settings_DoMelee);
                provider.PetAssist = SharedLib.ConvertToBoolean(IniFileProvider.ReadValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetAssist), Defaults.Default_Settings_DoMelee);

                provider.MeleeSettingsProvider = MeleeSettingsProvider.LoadFromINI(provider, filepath);
                provider.HealSettingsProvider = HealSettingsProvider.LoadFromINI(provider, filepath);
                provider.BuffSettingsProvider = BuffSettingsProvider.LoadFromINI(provider, filepath);
                provider.DebuffSettingsProvider = DebuffSettingsProvider.LoadFromINI(provider, filepath);
                provider.EventSettingsProvider = EventSettingsProvider.LoadFromINI(provider, filepath);
                provider.PullSettingsProvider = PullSettingsProvider.LoadFromINI(provider, filepath);
                
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return provider;
        }

        public static void SaveToIni(ModBotSettingsProvider provider, string filepath)
        {            
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoMelee, Convert.ToString(provider.DoMelee));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoHeals, Convert.ToString(provider.DoHeals));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoBuffs, Convert.ToString(provider.DoBuffs));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoDebuffs, Convert.ToString(provider.DoDebuffs));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoEvents, Convert.ToString(provider.DoEvents));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoCures, Convert.ToString(provider.DoCures));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoPull, Convert.ToString(provider.DoPull));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoPet, Convert.ToString(provider.DoPet));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoSit, Convert.ToString(provider.DoSit));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoLoot, Convert.ToString(provider.DoLoot));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoFW, Convert.ToString(provider.DoFW));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoForage, Convert.ToString(provider.DoForage));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_ForageIni, Convert.ToString(provider.ForageIni));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoAfk, Convert.ToString(provider.DoAfk));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DoMount, Convert.ToString(provider.DoMount));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_MountCast, Convert.ToString(provider.MountCast));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_MasterList, Convert.ToString(provider.MasterList));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_TankName, Convert.ToString(provider.TankName));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_Radius, Convert.ToString(provider.Radius));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_SitAggroRadiusCheck, Convert.ToString(provider.SitAggroRadiusCheck));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_AfkMessage, Convert.ToString(provider.AfkMessage));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_DeathSlot, Convert.ToString(provider.DeathSlot));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_NetworkIni, Convert.ToString(provider.NetworkIni));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_TraderName, Convert.ToString(provider.TraderName));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_FollowDistance, Convert.ToString(provider.FollowDistance));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_FollowStick, Convert.ToString(provider.FollowStick));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetCast, Convert.ToString(provider.PetCast));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetAggro, Convert.ToString(provider.PetAggro));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetFoci, Convert.ToString(provider.PetFoci));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetShrinkSpell, Convert.ToString(provider.PetShrinkSpell));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetShrink, Convert.ToString(provider.PetShrink));
            IniFileProvider.WriteValue(filepath, Keys.Settings_Section_Key, Keys.Settings_Key_PetAssist, Convert.ToString(provider.PetAssist));

            MeleeSettingsProvider.SaveToIni(provider.MeleeSettingsProvider, filepath);
            HealSettingsProvider.SaveToIni(provider.HealSettingsProvider, filepath);
            BuffSettingsProvider.SaveToIni(provider.BuffSettingsProvider, filepath);
            DebuffSettingsProvider.SaveToIni(provider.DebuffSettingsProvider, filepath);
            EventSettingsProvider.SaveToIni(provider.EventSettingsProvider, filepath);
            PullSettingsProvider.SaveToIni(provider.PullSettingsProvider, filepath);
        }
    }
}
